<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Discussion extends Model
{
    protected $fillable=['title','body','user_id','last_user_id'];

    public function user()
    {
        return $this->belongsTo(User::class,'user_id');
    }

    public function comments()
    {
        return $this->hasMany(Comment::class);
    }

    public function tags()
    {
        return $this->belongsToMany('App\Models\Tag','discussion_tag','discussion_id','tag_id');
    }
    public function categories()
    {
        return $this->belongsToMany('App\Models\Category','discussion_category','discussion_id','category_id');
    }
}
